<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>病人信息录入</title>
    <link rel="stylesheet" href="layui/css/layui.css" />
</head>

<body style="padding:20px">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>信息录入</legend>
    </fieldset>
    <form class="layui-form" action=" " lay-filter="formUpdate">

        <div class="layui-form-item">
            <label class="layui-form-label">病人姓名</label>
            <div class="layui-input-block">
                <input type="text" name="patientName" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block">
                <input type="text" name="patientSex" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">年龄</label>
            <div class="layui-input-block">
                <input type="text" name="patientAge" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                    class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">所属科室</label>
            <div class="layui-input-block">
                <input type="text" name="patientDepartment" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">主治医生</label>
            <div class="layui-input-block">
                <select class="stype" name="dp" id="dp" lay-verify="required" lay-filter="xmFilter">
                    <option value="">请选择主治医生</option>
                </select>
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">临床诊断</label>
            <div class="layui-input-block">
                <input type="text" name="patientDisease" lay-verify="title" autocomplete="off" placeholder="请输入内容"
                    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">入院日期</label>
            <div class="layui-input-inline">
                <input type="text" name="patientDate" id="date" lay-verify="date" placeholder="请选择日期" autocomplete="off"
                    class="layui-input">
            </div>
        </div>


        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="submitPat">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>

    <script type="text/javascript" src="layui/layui.js"></script>
    <script>
        layui.use(['layer', 'laydate', 'form', 'jquery'], function () {
            var layer = layui.layer;
            var laydate = layui.laydate;
            var form = layui.form;
            var $ = layui.jquery


            laydate.render({
                elem: '#date'
            });


            form.render();

            layui.use(['form', 'upload', 'layer'], function () {
                var form = layui.form;
                $.ajax({
                    url: 'http://localhost:8080/mid/getDoc',
                    dataType: 'json',
                    type: 'get',

                    success: function (data) {
                        console.log(data),
                            $.each(data.data, function (index, value) {
                                $('#dp').append(new Option(value.doctorName));
                            });
                        layui.form.render("select");
                    }
                })
            })


            form.on('submit(submitPat)', function (data) {


                $.ajax({
                    url: 'http://localhost:8080/patient/addPat',
                    type: 'POST',
                    dataType: 'JSON',
                    data: data.field,
                    success: function (result) {


                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);

                        parent.table.reload("Patient");
                    }
                })


                return false;
            });
        });
    </script>
</body>

</html>